<template>
    <div class="wrapper" ref="wrapper">
       <div class="content">
       <div v-for="(item,index) in $store.state.cartList" :key="index" >
           <div id="shop-item">
        <div class="item-selector">
    <div class="icon-selector" :class="{'selector-active': item.xuanz}" @click="addclick(index)">
        <img v-show="item.xuanz" src="~/assets/img/cart/tick.svg" alt="">
      </div>
    </div>
       <div class="item-img">
      <img :src="item.image" alt="商品图片">
    </div>
    <div class="item-info">
      <div class="item-title">{{item.title}}</div>
      <div class="item-desc">{{item.desc}}</div>
      <div class="info-bottom">
        <div class="item-price left">¥{{item.price}}</div>
        <div class="item-count right">x{{item.count}}</div>
      </div>
    </div>
  </div>
       </div>
       </div>
    </div>
</template>

<script>
import BScroll from 'better-scroll'




export default {
    name:'Categorylb',
    components:{ 
    },
    data(){
        return{
           backtop:null,
            
        }
    },
    methods:{
      addclick(index){
        this.$store.state.cartList[index].xuanz=!this.$store.state.cartList[index].xuanz
     
      }
    },
    mounted(){
       //创建bscroll对象
        this.backtop=new BScroll(this.$refs.wrapper,{
        //在scroll里需要点击click：true
        click:true,
        //开启监听滚动事件
        probeType:3,
        //上拉加载更多
        pullUpLoad:false
                  
                   } )  
    
    },
   
   activated(){
         this.backtop.refresh()
   }
    

   
}
</script>

<style scoped>
.wrapper{
  
   height: 100vh;
   
    
}
.content{
 
 overflow: hidden;
}
 #shop-item {
    width: 100%;
    display: flex;
    font-size: 0;
    padding: 5px;
    border-bottom: 1px solid #ccc;
  }

  .item-selector {
    width: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .item-title, .item-desc {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .item-img {
    padding: 5px;
    /*border: 1px solid #ccc;*/
  }

  .item-img img {
    width: 80px;
    height: 100px;
    display: block;
    border-radius: 5px;
  }

  .item-info {
    font-size: 17px;
    color: #333;
    padding: 5px 10px;
    position: relative;
    overflow: hidden;
  }

  .item-info .item-desc {
    font-size: 14px;
    color: #666;
    margin-top: 15px;
  }

  .info-bottom {
    margin-top: 10px;
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
  }

  .info-bottom .item-price {
    color: orangered;
  }

   .icon-selector {
    position: relative;
    margin: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #ccc;
    cursor: pointer;
  }

  .selector-active {
    background-color: #ff8198;
    border-color: #ff8198;
  }
</style>